using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using Microsoft.ApplicationBlocks.Data;

namespace Customs.Components.SXXK.TOKHAI
{
    public class HangDieuChinh
    {
        /// <summary>
        /// Lay Thong Tin Hang dieu chinh thue cua mot to khai
        /// </summary>
        /// <param name="maHaiQuan"></param>
        /// <param name="maloaihinh"></param>
        /// <param name="sotk"></param>
        /// <param name="namdk"></param>
        /// <returns></returns>
        public static DataSet GetDanhSachHangDieuChinhOfToKhai(string maHaiQuan, string maloaihinh, int sotk, short namdk)
        {
            string connectionString = ConnectionManager.GetConnectionString("SXXK", maHaiQuan);
            string query = "SELECT     dbo.DHANGMDDC.* from dbo.DHANGMDDC  where MA_HQ=@MA_HQ and MA_LH=@MA_LH AND NAMDK=@NAMDK AND SOTK=@SOTK";

            SqlParameter[] parameters = new SqlParameter[4];

            parameters[0] = new SqlParameter("@Ma_HQ", SqlDbType.Char);
            parameters[0].Size = 6;
            parameters[0].Direction = ParameterDirection.Input;
            parameters[0].Value = maHaiQuan;

            parameters[1] = new SqlParameter("@MA_LH", SqlDbType.Char);
            parameters[1].Size = 5;
            parameters[1].Direction = ParameterDirection.Input;
            parameters[1].Value = maloaihinh;

            parameters[2] = new SqlParameter("@SOTK", SqlDbType.Int);
            parameters[2].Value = sotk;

            parameters[3] = new SqlParameter("@NAMDK", SqlDbType.SmallInt);
            parameters[3].Value = namdk;

            return SqlHelper.ExecuteDataset(connectionString, CommandType.Text, query, parameters);

        }
        /// <summary>
        /// Lay Thong tin dieu chinh thue cua to khai cua mot doanh nghiep
        /// </summary>
        /// <param name="maHaiQuan"></param>
        /// <param name="maDoanhNghiep"></param>
        /// <returns></returns>
        public static DataSet GetDanhSachHangDieuChinh(string maHaiQuan, string maDoanhNghiep)
        {
            string connectionString = ConnectionManager.GetConnectionString("SXXK", maHaiQuan);
            string query = "SELECT     dbo.DHANGMDDC.* " +
                           "FROM         dbo.DTOKHAIMD INNER JOIN " +
                           "dbo.DHANGMDDC ON dbo.DTOKHAIMD.SOTK = dbo.DHANGMDDC.SOTK AND dbo.DTOKHAIMD.MA_LH = dbo.DHANGMDDC.MA_LH AND " +
                           "dbo.DTOKHAIMD.MA_HQ = dbo.DHANGMDDC.MA_HQ AND dbo.DTOKHAIMD.NAMDK = dbo.DHANGMDDC.NAMDK " +
                           "where dbo.DTOKHAIMD.MA_HQ=@Ma_HQ AND dbo.DTOKHAIMD.MA_DV=@MA_DV";

            SqlParameter[] parameters = new SqlParameter[2];

            parameters[0] = new SqlParameter("@Ma_HQ", SqlDbType.Char);
            parameters[0].Size = 6;
            parameters[0].Direction = ParameterDirection.Input;
            parameters[0].Value = maHaiQuan;

            parameters[1] = new SqlParameter("@Ma_DV", SqlDbType.VarChar);
            parameters[1].Size = 14;
            parameters[1].Direction = ParameterDirection.Input;
            parameters[1].Value = maDoanhNghiep;

            return SqlHelper.ExecuteDataset(connectionString, CommandType.Text, query, parameters);

        }

        /// <summary>
        /// Lay Thong Tin chi tiet Hang dieu chinh thue cua mot to khai
        /// </summary>
        /// <param name="maHaiQuan"></param>
        /// <param name="maloaihinh"></param>
        /// <param name="sotk"></param>
        /// <param name="namdk"></param>
        /// <returns></returns>
        public static DataSet GetDanhSachChiTietHangDieuChinhOfToKhai(string maHaiQuan, string maloaihinh, int sotk, short namdk)
        {
            string connectionString = ConnectionManager.GetConnectionString("SXXK", maHaiQuan);
            string query = "SELECT     dbo.DHANGMDDC_CT.* from DHANGMDDC_CT where MA_HQ=@MA_HQ and MA_LH=@MA_LH AND NAMDK=@NAMDK AND SOTK=@SOTK";

            SqlParameter[] parameters = new SqlParameter[4];

            parameters[0] = new SqlParameter("@Ma_HQ", SqlDbType.Char);
            parameters[0].Size = 6;
            parameters[0].Direction = ParameterDirection.Input;
            parameters[0].Value = maHaiQuan;

            parameters[1] = new SqlParameter("@MA_LH", SqlDbType.Char);
            parameters[1].Size = 5;
            parameters[1].Direction = ParameterDirection.Input;
            parameters[1].Value = maloaihinh;

            parameters[2] = new SqlParameter("@SOTK", SqlDbType.Int);
            parameters[2].Value = sotk;

            parameters[3] = new SqlParameter("@NAMDK", SqlDbType.SmallInt);
            parameters[3].Value = namdk;

            return SqlHelper.ExecuteDataset(connectionString, CommandType.Text, query, parameters);

        }
        /// <summary>
        /// Lay Thong tin hang dieu chinh chi tiet thue cua to khai cua mot doanh nghiep
        /// </summary>
        /// <param name="maHaiQuan"></param>
        /// <param name="maDoanhNghiep"></param>
        /// <returns></returns>
        public static DataSet GetDanhSachHangDieuChinhChiTiet(string maHaiQuan, string maDoanhNghiep)
        {
            string connectionString = ConnectionManager.GetConnectionString("SXXK", maHaiQuan);
            string query = "SELECT     dbo.DHANGMDDC_CT.* " +
                           "FROM         dbo.DTOKHAIMD INNER JOIN " +
                           "dbo.DHANGMDDC_CT ON dbo.DTOKHAIMD.SOTK = dbo.DHANGMDDC_CT.SOTK AND dbo.DTOKHAIMD.MA_LH = dbo.DHANGMDDC_CT.MA_LH AND " +
                           "dbo.DTOKHAIMD.MA_HQ = dbo.DHANGMDDC_CT.MA_HQ AND dbo.DTOKHAIMD.NAMDK = dbo.DHANGMDDC_CT.NAMDK " +
                           "where dbo.DTOKHAIMD.MA_HQ=@Ma_HQ AND dbo.DTOKHAIMD.MA_DV=@MA_DV";

            SqlParameter[] parameters = new SqlParameter[2];

            parameters[0] = new SqlParameter("@Ma_HQ", SqlDbType.Char);
            parameters[0].Size = 6;
            parameters[0].Direction = ParameterDirection.Input;
            parameters[0].Value = maHaiQuan;

            parameters[1] = new SqlParameter("@Ma_DV", SqlDbType.VarChar);
            parameters[1].Size = 14;
            parameters[1].Direction = ParameterDirection.Input;
            parameters[1].Value = maDoanhNghiep;

            return SqlHelper.ExecuteDataset(connectionString, CommandType.Text, query, parameters);

        } 
    }
}
